package org.xx.armory.swing.builders;

import static org.apache.commons.lang3.StringUtils.left;
import static org.apache.commons.lang3.StringUtils.trimToEmpty;

public class LabelModelBuilder
        extends ComponentModelBuilder<LabelModel> {
    private String text;
    private String mnemonic;
    private String forName;
    private boolean html;
    private ModelAlignment alignment;

    public LabelModelBuilder() {
    }

    public LabelModelBuilder setText(
            String text
    ) {
        this.text = text;
        return this;
    }

    public LabelModelBuilder setMnemonic(
            String mnemonic
    ) {
        this.mnemonic = mnemonic;
        return this;
    }

    public LabelModelBuilder setForName(
            String forName
    ) {
        this.forName = forName;
        return this;
    }

    public LabelModelBuilder setHtml(
            boolean html
    ) {
        this.html = html;
        return this;
    }

    public LabelModelBuilder setAlignment(
            ModelAlignment alignment
    ) {
        this.alignment = alignment;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public LabelModel build() {
        this.mnemonic = left(trimToEmpty(this.mnemonic), 1);
        return new LabelModel(getLineInfo(), getName(), isVisible(), this.text,
                              !mnemonic.isEmpty() ? mnemonic.charAt(0) : '\0',
                              trimToEmpty(this.forName), this.html, this.alignment);
    }
}
